package com.tourism.controller;


import com.tourism.common.Result;
import com.tourism.service.UserRouteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/api/user/route")
@Slf4j
@CrossOrigin
public class UserRouteController {

    @Autowired
    private UserRouteService userRouteService;

    /**
     * 选择路线
     * @param userId 用户ID
     * @param routeId 路线ID
     * @return Result
     */
    @GetMapping("/select")
    public Result selectRoute(@RequestParam("userId") Integer userId,
                              @RequestParam("routeId") Integer routeId) {
        return userRouteService.selectRoute(userId, routeId);
    }

    /**
     * 获取用户当前选择的路线
     * @param userId 用户ID
     * @return Result
     */
    @GetMapping("/current")
    public Result getCurrentRoute(@RequestParam("userId") Integer userId) {
        return userRouteService.getCurrentRoute(userId);
    }

    /**
     * 取消用户选择的路线
     * @param userId 用户ID
     * @return Result
     */
    @GetMapping("/cancel")
    public Result cancelRoute(@RequestParam("userId") Integer userId) {
        return userRouteService.cancelRoute(userId);
    }
}
